#include<linux/module.h>
#include<linux/init.h>
#include<linux/kallsyms.h>
MODULE_LICENSE("GPL");
static int __init sprint_symbol_init(void);
static void __exit sprint_symbol_exit(void);

int a_symbol(void)
{
	return -1;
}
EXPORT_SYMBOL(a_symbol);

int __init sprint_symbol_init(void)
{
	char buffer[KSYM_SYMBOL_LEN];
	int ret;
	unsigned long address;
	char *name;
	struct module *fmodule=NULL;
	address=(unsigned long) __builtin_return_address(0); //current func return address

	ret=sprint_symbol(buffer,address);
	printk("ret: %d\n",ret);
	printk("buffer: %s\n",buffer);
	printk("\n");

	name="test_module";
	fmodule=find_module(name);
	if(fmodule !=NULL)
	{
		printk("fmodule->name: %s\n",fmodule->name);	
		address=(unsigned long)fmodule->module_core;
		ret=sprint_symbol(buffer,address);
		printk("ret: %d\n",ret);
		printk("buffer: %s\n",buffer);
	}
	printk("\n");
	address=(unsigned long)a_symbol+5;
	ret=sprint_symbol(buffer,address);
	printk("ret: %d\n",ret);
	printk("buffer: %s\n",buffer);
	return 0;
}
void __exit sprint_symbol_exit(void)
{
	printk("module exit ok!\n");
}
module_init(sprint_symbol_init);
module_exit(sprint_symbol_exit);
